package org.luckyjourney.service.agent.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.luckyjourney.entity.agent.AgentChat;
import org.luckyjourney.mapper.agent.AgentChatMapper;
import org.luckyjourney.mapper.agent.AgentChatTableMapper;
import org.luckyjourney.service.agent.AgentChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* @author 86155
* @description 针对表【agent_chat(3智能体对话表)】的数据库操作Service实现
* @createDate 2024-03-21 17:00:29
*/
@Service
public class AgentChatServiceImpl extends ServiceImpl<AgentChatMapper, AgentChat>
    implements AgentChatService {
    @Autowired
    private AgentChatMapper  agentChatMapper;

    @Autowired
    private AgentChatTableMapper agentChatTableMapper;


    @Override
    public int bathRemoveById(int agent_chat_id) {
        List<AgentChat> agentChats = agentChatMapper.selectList(new LambdaQueryWrapper<AgentChat>().eq(AgentChat::getAgentChatId, agent_chat_id));
        if (agentChats.size() > 0) {
            agentChats.forEach(agentChat -> {
                agentChatMapper.deleteById(agentChat.getChatId());
            });
            return 1;
         }else {
            return 0;
        }

    }

    @Override
    public void saveOrUpdates(String resultPath, int chatId) {
        agentChatMapper.saveOrUpdates(resultPath,chatId);
    }


}




